import {DirectiveBinding} from 'vue'
// 弹窗拖拽鼠标移动指令函数
export function handleMove (el: HTMLElement, binding: DirectiveBinding) {
    const headel = el.querySelector(".xw-dialog__header") as HTMLElement;
    headel.style.cursor = 'move'
    console.log('binding',binding);
    
    const elMouseDown = (e: MouseEvent) => {
      const X = e.clientX - el.offsetLeft;
      const Y = e.clientY - el.offsetTop;
      let isDown = true;
      const mouseMove = (e: MouseEvent) => {
        if (!isDown) {
          return;
        }
        el.style.left = e.clientX - X + "px";
        el.style.top = e.clientY - Y + "px";
      };
      document.addEventListener("mousemove", mouseMove);
      headel.addEventListener("mouseup", () => {
        document.removeEventListener("mousemove", mouseMove);
      });
    };
  
    headel.addEventListener("mousedown", elMouseDown);
  };